<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>供货商信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" type="text/css" href="../common/layui/css/layui.css" media="all">
	<link rel="stylesheet" type="text/css" href="../common/bootstrap/css/bootstrap.css" media="all">
	<link rel="stylesheet" type="text/css" href="../common/global.css" media="all">
	<link rel="stylesheet" type="text/css" href="../css/personal.css" media="all">
</head>
<body>
<!--此页面未供货商信息修改页面-->
<section class="layui-larry-box">
	<div class="larry-personal">
		<header class="larry-personal-tit">
			<span>供货商信息</span>
		</header><!-- /header -->
		<div class="larry-personal-body clearfix">
			<form class="layui-form col-lg-5" action="" method="post" id="em_upinfo">
				<div class="layui-form-item">
					<label class="layui-form-label">供货商名称</label>
					<div class="layui-input-block">
						<input type="text" id="em_name" name="name"  autocomplete="off" class="layui-input" value="">
						<input type="text" id="em_id" name="id"  autocomplete="off" class="layui-input" value="" hidden="hidden">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">地址</label>
					<div class="layui-input-block">
						<input type="text" id="admin_name" name="address"  autocomplete="off" class="layui-input" value="">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">联系人</label>
					<div class="layui-input-block">
						<input type="text" id="su_linkman" name="linkman"  autocomplete="off" class="layui-input" value="">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">联系电话</label>
					<div class="layui-input-block">
						<input type="text" id="em_phonenum" name="phonenum"  autocomplete="off" class="layui-input" placeholder="输入手机号码">
						<!--添加员工默认在职-->
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">邮编号码</label>
					<div class="layui-input-block">
						<input type="text" id="su_postcode" name="postcode"  autocomplete="off" class="layui-input" placeholder="输入手机号码">
						<!--添加员工默认在职-->
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">传真号码</label>
					<div class="layui-input-block">
						<input type="text" id="su_faxnum" name="faxnum"  autocomplete="off" class="layui-input" placeholder="输入手机号码">
						<!--添加员工默认在职-->
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">邮箱账号</label>
					<div class="layui-input-block">
						<input type="text" id="su_email" name="email"  autocomplete="off" class="layui-input" placeholder="输入手机号码">
						<!--添加员工默认在职-->
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">合作状态</label>
					<div class="layui-input-inline">
						<select name="state" class="newsLook" lay-filter="browseLook" id="em_state">
							<option value="0" >合作</option>
							<option value="1" >未合作</option>
						</select>
					</div>
				</div>


				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" type="button" onclick="addemployee()" lay-filter="demo1">立即修改</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
	</div>


</section>
<script type="text/javascript" src="../common/layui/lay/dest/layui.all.js"></script>
<script src="../jsplug/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="../jsplug/jparticle.jquery.js"></script>
<script type="text/javascript" src="../common/layui/layui.js"></script>
<script src="../js/token.js"></script>
<script type="text/javascript">
	/**
	 * 修改员工信息(根据id)
	 * 先获取从url传来的参数
	 */
	$(function (){
		var id = location.search.split("=")[1];
		document.getElementById("em_id").value=id;
		$.post("/supplier/toupdata",{id:id},function (res){
			$("#em_name").val(res.data.name);
			$("#admin_name").val(res.data.address);
			$("#su_linkman").val(res.data.linkman);
			$("#em_phonenum").val(res.data.phonenum);
			$("#su_postcode").val(res.data.postcode);
			$("#su_faxnum").val(res.data.faxnum);
			$("#su_email").val(res.data.email);
		/*状态*/
			if (res.data.state==0){
				document.getElementById("em_state").options[0].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else {
				document.getElementById("em_state").options[1].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}

		},"json")
	})





	/*添加员工操作*/
	function addemployee(){
		$.post("/supplier/savesupplier",$("#em_upinfo").serialize(),function(res){
			layer.confirm('供货商添加成功，前往查看！', {
			icon: 1,        //会出现正确的图片
			btn: ['好']     //按钮
		}, function(){
			window.location.href="supplier_table.html";//点击“好”后进行跳转
		});

		},"json")
}





	layui.use(['form','upload'],function(){
		var form = layui.form();
		form.render();
		layui.upload({
			url: '' ,//上传接口
			success: function(res){
				//上传成功后的回调
				console.log(res)
			}
		});

	});

</script>
</body>
</html>